#ifndef MOONLIGHT_OHOS_PCMBUFFERSPAN_H
#define MOONLIGHT_OHOS_PCMBUFFERSPAN_H

#include <opus_types.h>
#include <memory>

struct PcmBufferSpan {
    using sample_t = opus_int16;

    std::unique_ptr<sample_t[]> buffer;
    int64_t lengthInBytes;
    int64_t consumedBytes;

    PcmBufferSpan();
    PcmBufferSpan(PcmBufferSpan &&that);
    PcmBufferSpan &operator=(PcmBufferSpan &&that);

    sample_t *currentData() const;
    int64_t remainingBytes() const;
    void advanceBytes(int64_t length);

private:
    PcmBufferSpan(const PcmBufferSpan &) = delete;
    PcmBufferSpan &operator=(const PcmBufferSpan &) = delete;
};

#endif //MOONLIGHT_OHOS_PCMBUFFERSPAN_H
